package com.valley.dream.birds;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.valley.dream.birds.fragment.LoginFragment;
import com.valley.dream.birds.fragment.RegisterFragment;
import com.valley.dream.birds.login.ServiceActivity;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initLoginOrRegister(new LoginFragment());
    }

    private void initLoginOrRegister(Fragment fragment) {
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.replace(R.id.layout_login_register, fragment);
        transaction.commit();
    }

    public void initLoginClick(View view) {
        initLoginOrRegister(new LoginFragment());
    }

    public void initRegisterClick(View view) {
        initLoginOrRegister(new RegisterFragment());
    }

    public void loginClick(View view) {
        startActivity(new Intent(this, ServiceActivity.class));
    }

}